<?php

class Task extends AppModel
{

    var $name = 'Task';
    var $displayField = 'name';
    var $order = array('Task.name' => 'ASC');
    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $belongsTo = array(
        'Potential' => array(
            'className' => 'Potential',
            'foreignKey' => 'potential_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Tasktemplate' => array(
            'className' => 'Tasktemplate',
            'foreignKey' => 'tasktemplate_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Employee' => array(
            'className' => 'Employee',
            'foreignKey' => 'employee_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Assignedtoemployee' => array(
            'className' => 'Employee',
            'foreignKey' => 'assignedtoemployee_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
    var $validate = array(
        'potential_id' => array(
            'numeric' => array(
                'rule' => 'numeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose a potential'
            )
        ),
        'name' => array(
            'notEmpty' => array(
                'rule' => 'notEmpty',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please enter name'
            ),
            'minLength' => array(
                'rule' => array('minLength', 2),
                'message' => 'Name should be atleast 2 characters long'
            )
        ),
        'tasktemplate_id' => array(
            'numeric' => array(
                'rule' => 'numeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose a task template'
            )
        ),
        'duedate' => array(
            'date' => array(
                'rule' => array('date', 'dmy'),
                'required' => true,
                'allowEmpty' => false,
                'message' => 'Please enter a valid due date'
            ),
            'notEmpty' => array(
                'rule' => 'notEmpty',
                'message' => 'Please enter a valid due date'
            )
        ),
        'nextfollowupdate' => array(
            'date' => array(
                'rule' => array('date', 'dmy'),
                'required' => true,
                'allowEmpty' => false,
                'message' => 'Please enter a valid followup date'
            ),
            'notEmpty' => array(
                'rule' => 'notEmpty',
                'message' => 'Please enter a valid followup date'
            )
        ),
        'employee_id' => array(
            'numeric' => array(
                'rule' => 'numeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose an employee'
            )
        ),
        'assignedtoemployee_id' => array(
            'numeric' => array(
                'rule' => 'numeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose an employee to whom this task be assigned to'
            )
        ),
        'priority' => array(
            'numeric' => array(
                'rule' => 'numeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose a priority for this task'
            )
        )
    );
}
?>